package com.miniapp.web.controller.paicfti;

import com.miniapp.common.annotation.Log;
import com.miniapp.common.core.controller.BaseController;
import com.miniapp.common.core.domain.AjaxResult;
import com.miniapp.common.core.page.TableDataInfo;
import com.miniapp.common.enums.BusinessType;
import com.miniapp.common.utils.poi.ExcelUtil;

import com.miniapp.core.domain.PaicFtiAgentGen;
import com.miniapp.core.service.IPaicFtiAgentGenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 平安货运险代理人Controller（废弃，小程序代理人功能 替代此功能）
 *
 * @author ruoyi
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/core/agent")
public class PaicFtiAgentGenController extends BaseController
{
    @Autowired
    private IPaicFtiAgentGenService paicFtiAgentGenService;

    /**
     * 查询平安货运险代理人列表
     */
    @PreAuthorize("@ss.hasPermi('core:agent:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaicFtiAgentGen paicFtiAgentGen)
    {
        startPage();
        List<PaicFtiAgentGen> list = paicFtiAgentGenService.selectPaicFtiAgentGenList(paicFtiAgentGen);
        return getDataTable(list);
    }

    /**
     * 导出平安货运险代理人列表
     */
    @PreAuthorize("@ss.hasPermi('core:agent:export')")
    @Log(title = "平安货运险代理人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaicFtiAgentGen paicFtiAgentGen)
    {
        List<PaicFtiAgentGen> list = paicFtiAgentGenService.selectPaicFtiAgentGenList(paicFtiAgentGen);
        ExcelUtil<PaicFtiAgentGen> util = new ExcelUtil<PaicFtiAgentGen>(PaicFtiAgentGen.class);
        util.exportExcel(response, list, "平安货运险代理人数据");
    }

    /**
     * 获取平安货运险代理人详细信息
     */
    @PreAuthorize("@ss.hasPermi('core:agent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paicFtiAgentGenService.selectPaicFtiAgentGenById(id));
    }

    /**
     * 新增平安货运险代理人
     */
    @PreAuthorize("@ss.hasPermi('core:agent:add')")
    @Log(title = "平安货运险代理人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaicFtiAgentGen paicFtiAgentGen)
    {
        return toAjax(paicFtiAgentGenService.insertPaicFtiAgentGen(paicFtiAgentGen));
    }

    /**
     * 修改平安货运险代理人
     */
    @PreAuthorize("@ss.hasPermi('core:agent:edit')")
    @Log(title = "平安货运险代理人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaicFtiAgentGen paicFtiAgentGen)
    {
        return toAjax(paicFtiAgentGenService.updatePaicFtiAgentGen(paicFtiAgentGen));
    }

    /**
     * 删除平安货运险代理人
     */
    @PreAuthorize("@ss.hasPermi('core:agent:remove')")
    @Log(title = "平安货运险代理人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paicFtiAgentGenService.deletePaicFtiAgentGenByIds(ids));
    }
}
